#pragma once

#include "BlocksConsts.h"

class CanInterface;

struct Cell
{
	unsigned char x;
	unsigned char y;
};

class Block
{
public:
	Block::Block(CanInterface* can, unsigned char figIndex = 0, unsigned char rotIndex = 0);

public:
	void MoveLeft();
	void MoveRight();
	bool MoveDown();
	void Rotate();
	void FallDown();

public:
	void CheckLines();

public:
	void PutOnTop();
	void Update(unsigned char figIndex, unsigned char rotIndex);

private:
	bool _CheckCells(int x_offs, int y_offs);
	void _UpdateMyCells(unsigned char value);

private:
	unsigned char _figIndex;
	unsigned char _rotIndex;
	unsigned char _color;
	Cell	 _cell[FIGURE_COMPLEXITY];

private:
	CanInterface*	_can;
};